package com.neu.app;

import com.neu.view.UserView;
import com.neu.view.impl.AdminView;
import com.neu.view.impl.BussinessView;
import org.w3c.dom.ls.LSOutput;

import java.util.Map;
import java.util.Scanner;

public class App {

    /*程序入口*/
    public static void main(String[] args) {
        main();
    }
    public static void main() {
        System.out.println("欢迎使用饿了么后台管理系统：");
        int n=0;
        UserView userView = null;
        while (n!=1&&n!=2){
            System.out.println("请选择身份：");
            System.out.println("1.管理员||2.商家");
            System.out.println("请选择：");
            Scanner in = new Scanner(System.in);
            n = in.nextInt();
            switch (n){
                case 1:
                    userView =new AdminView();
                    break;
                case 2:
                    userView = new BussinessView();
                    break;
                default:
                    System.out.println("请输入1或2！");
                    break;
            }
        }
        if (userView == null){
            System.exit(0);
        }
        Map<String ,Object> map = userView.login();
        if (map!=null){
            userView.setInfo(map);
            userView.menu();
        }
        else{
            System.out.println("用户名或密码有误！请重新输入");
            main();
        }
    }
}
